from typing import List


class Solution:
    def minimumTime(self, time: List[int], totalTrips: int) -> int:
        if len(time) == 1:
            return time[0] * totalTrips
        time.sort()
        left = 0
        right = time[-1] * totalTrips + 1
        while left + 1 < right:
            mid = (left + right) // 2
            if self.can_complete(time, mid, totalTrips):
                right = mid
            else:
                left = mid
        return right

    def can_complete(self, time: List[int], total_time: int, totalTrips: int):
        trips = 0
        for t in time:
            trips += total_time // t
        return trips >= totalTrips
